<template id="collage_map">
	<div class="collage_map">

	
		<div id="allmap"></div>

	</div>
</template>

<script>
	export default {
		name: 'App',
		components: {},
		data() {
			return {
				address_detail: '', //详细地址
				lng: this.$route.query.lng,
				lat: this.$route.query.lat

			}
		},

		mounted() {
			console.log(this.lng)
			console.log(this.lat)
			var map = new BMap.Map("allmap");
			var point = new BMap.Point(this.lng, this.lat);
//			console.log(point)
			map.centerAndZoom(point, 16);
			map.enableScrollWheelZoom();

			var myIcon = new BMap.Icon("myicon.png", new BMap.Size(30, 30), {
				anchor: new BMap.Size(10, 10)
			});

			var marker = new BMap.Marker(point, {
				icon: myIcon
			});
			map.addOverlay(marker);

			var geolocation = new BMap.Geolocation();
			geolocation.getCurrentPosition(function(r) {
				if(this.getStatus() == BMAP_STATUS_SUCCESS) {
					var mk = new BMap.Marker(r.point);
					
					map.addOverlay(mk);
//					console.log(mk)
					//map.panTo(r.point);//地图中心点移到当前位置 
					var latCurrent = r.point.lat;
					var lngCurrent = r.point.lng;
//					alert('我的位置：' + latCurrent + ',' + lngCurrent);

					location.href = "http://api.map.baidu.com/direction?origin=" + latCurrent + "," + lngCurrent + "&destination=39.89962,116.335151&mode=driving&region=北京&output=html";

				} else {
					alert('failed' + this.getStatus());
				}
			}, {
				enableHighAccuracy: true
			})

			map.addOverlay(marker);
			var licontent = "<b>蜗牛瑜家</b><br>";
			licontent += "<span><strong>地址：</strong>北京市西城区广莲路1号建工大厦A座4层</span><br>";
			licontent += "<span><strong>电话：</strong>176-0103-6600</span><br>";
			var opts = {
				width: 200,
				height: 80,
			};
			  var  infoWindow = new BMap.InfoWindow(licontent, opts);   
			  marker.openInfoWindow(infoWindow);   
			  marker.addEventListener('click',function(){ 
			      marker.openInfoWindow(infoWindow); 
			  });  

		},

		methods: {

		}
	}
</script>

<style>
	#allmap {
		width: 100%;
		height: 600px;
		font-family: "微软雅黑";
	}
</style>